#
# role for keepalived
# This role needs several variables defined:
#
# keepalived_interface - interface to listen on
# keepalived_priority - priority of this host
# keepalived_ipaddress - virtual ip address on master host
#

- name: Install keepalived package
  package: state=present name=keepalived
  tags:
  - packages
  - keepalived

- name: Install keepalived template
  template: src=keepalived.conf.j2 dest=/etc/keepalived/keepalived.conf
  tags:
  - config
  - keepalived
  notify:
  - restart keepalived

- name: Install keepalived failover script for host (or default)
  copy: src={{ item }} dest=/usr/local/bin/keepalived-notify.sh mode=755
  with_first_found:
    - keepalived-notify.sh.{{ inventory_hostname }}
    - keepalived-notify.sh
  tags:
  - config
  - keepalived

- name: Make sure keepalived is set to start and is running
  service: state=started enabled=true name=keepalived
  tags:
  - service
  - keepalived
